import 'package:flutter/material.dart';

/// 标题栏
class MyAppbar extends StatelessWidget implements PreferredSizeWidget {
  const MyAppbar({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return AppBar(
      elevation: 5,
      flexibleSpace: Image.asset(
        "assets/images/bar.png",
        fit: BoxFit.cover,
      ),
      brightness: Brightness.light,
      titleSpacing: 8.0,
      title: Container(
        padding: EdgeInsets.all(8.0),
        decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(8.0),
            color: Colors.grey[100],
            border: Border.all(
                color: Colors.black87, width: 0.5, style: BorderStyle.solid)),
        child: InkWell(
          onTap: () {
            // 跳转到搜索
          },
          child: Row(
            children: [
              Icon(
                Icons.search,
                size: 20,
              ),
              SizedBox(
                width: 5,
              ),
              Text(
                '搜索百万免费菜谱',
                style: TextStyle(color: Colors.black54, fontSize: 14),
              )
            ],
          ),
        ),
      ),
      leading: IconButton(
        onPressed: () {},
        icon: Icon(
          Icons.menu,
          color: Colors.black54,
        ),
      ),
      actions: [
        InkWell(
          child: Icon(
            Icons.email,
            color: Colors.black54,
          ),
        )
      ],
    );
  }

  @override
  Size get preferredSize => Size.fromHeight(55);
}
